package tp.pr5.console;

import java.util.Vector;

import tp.pr5.Directions;
import tp.pr5.GameObserver;
import tp.pr5.MapObserver;
import tp.pr5.Parser;
import tp.pr5.PlayerObserver;
import tp.pr5.RoomInfo;
import tp.pr5.items.Item;

public class Console implements GameObserver, PlayerObserver, MapObserver {
	public RoomInfo initialRoom;
	public int health, points;

	public Console() {

	}

	@Override
	public void playerHasExamineRoom(RoomInfo room) {
		System.out.println(room.getDescription());

		// Aqui faltaria pasarle a la gui el boton en color verde i guess!!!
	}

	@Override
	public void roomEntered(Directions direction, RoomInfo target) {
		// TODO Auto-generated method stub
		System.out.println(target.getDescription());

	}

	@Override
	public void inventoryUpdate(Vector<Item> inventory) {

	}

	@Override
	public void itemEmpty(String itemName) {
		System.out.println(itemName);
	}

	@Override
	public void itemLooked(String description) {

		System.out.println(description);
	}

	@Override
	public void itemUsed(String itemName) {
		System.out.println(itemName);
	}

	@Override
	public void playerDead() {
		// TODO Auto-generated method stub

	}

	@Override
	public void playerLookedInventory(Vector<Item> vectoritem) {

		// TODO Auto-generated method stub
		String LINE_SEPARATOR = System.getProperty("line.separator");
		String token;
		if (vectoritem.size() == 0) {
			System.out
					.println("You are poor. You have not got any item (yet).");
		} else {
			token = "My Items are:";
			for (int f = 0; f < vectoritem.size(); f++) {
				if (vectoritem.elementAt(f) != null) {
					token = token + LINE_SEPARATOR
							+ vectoritem.elementAt(f).toString();
				}
			}
			System.out.println(token);
		}
	}

	@Override
	public void playerUpdate(int health, int points) {
		this.health = health;
		this.points = points;
		System.out.println("HEALTH = " + this.health + "," + " SCORE ="
				+ this.points);

	}

	@Override
	public void gameError(String msg) {
		System.out.println(msg);
	}

	@Override
	public void gameHelp() {

		System.out.println(Parser.getHelp());
	}

	@Override
	public void gameOver(boolean win) {
		if (win) {
			System.out.println("Has ganado");
		} else {
			System.out.println("game over");
		}

	}

	@Override
	public void gameQuit() {
		// TODO Auto-generated method stub
		System.out.println("GAME OVER ");
		System.out.println(" Thank you for playing, goodbye.");
		System.out.println("HEALTH = " + this.health + "," + " SCORE ="
				+ this.points);

	}

	@Override
	public void gameStart(RoomInfo initialRoom, int playerPoints,
			int playerHealth) {
		this.health = playerHealth;
		this.points = playerPoints;
		System.out.println(initialRoom.getDescription());
		System.out.println("HEALTH = " + playerHealth + "," + " SCORE ="
				+ playerPoints);
	}
}
